﻿using Microsoft.AspNetCore.Mvc;
using SportsPlatform.Dto.SportBusiness.Information;
using SportsPlatform.SportBusiness.ISportBusiness;
using SportsPlatform.Base;
using SportsPlatform.Query.SportBusiness.Information;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SportsPlatform.Filters;

namespace SportsPlatform.Controllers
{
    /// <summary>
    /// 咨询管理控制器
    /// </summary>

    [ActionAuthorization]
    [Route("api/[controller]/[action]")]
    public class NewsController : SportsPlatformControllerBase
    {
        private INewsService _service;
        public NewsController(INewsService service)
        {
            this._service = service;
        }

        /// <summary>
        /// 获取资讯分页数据
        /// </summary>
        /// <param name="pageQuery">查询条件</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PagePagingDto<InformationDto>> GetInformationDtoPage([FromBody] GetInformationQuery pageQuery)
        {
            return await _service.GetPagePagingDto(pageQuery);
        }

        /// <summary>
        /// 添加资讯信息
        /// </summary>
        /// <param name="addInformationQuery">传入参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> AddInformation([FromBody] AddInformationQuery addInformationQuery)
        {
            return await _service.AddStart(addInformationQuery);
        }

        /// <summary>
        /// 更新资讯信息
        /// </summary>
        /// <param name="updateInformationQuery">传入参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> UpdateInformation([FromBody] UpdateInformationQuery updateInformationQuery)
        {
            return await _service.UpdateStart(updateInformationQuery);
        }

        /// <summary>
        /// 删除资讯
        /// </summary>
        /// <param name="deleteInformationQuery">传入参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> DeleteInformation([FromBody] DeleteInformationQuery deleteInformationQuery)
        {
            return await _service.DeleteStart(deleteInformationQuery);
        }

        /// <summary>
        /// 更新状态
        /// </summary>
        /// <param name="updateSateQuery">传入参数</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<BaseResultDto> UpdateNewsSate([FromBody] UpdateNewsSateQuery updateSateQuery)
        {
            return await _service.UpdateStateStart(updateSateQuery);
        }

        /// <summary>
        /// 通过标识获取对应资讯，并进行更新
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultDto<UpdateInformationQuery>> GetByIdUpdateNews(Guid Id)
        {
            return await _service.GetById(Id);
        }
    }
}
